home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-05-10 | 13.9 KB | 515 lines | [TEXT/MPS ] |
- { UReliefGridView.p }
- { Copyright © 1984-1990 Apple Computer, Inc. All rights reserved. }
-
- UNIT UReliefGridView;
-
- INTERFACE
-
- USES
- {$IFC UNDEFINED THINK_PASCAL}
- { • MacApp }
- UMacApp, Resources,
-
- {$ELSEC }
- SysEqu, Traps, ULoMem, UMacAppUtilities, UPatch, UObject, UViewCoords, UMemory, UFailure, UMenuSetup, UList, PrintTraps, UAssociation, UMacApp,
- {$ENDC}
-
- UGridView;
-
-
- CONST
-
- kBkgndColorRsrcType = 'BKCL';
- kSideColorRsrcType = 'SDCL';
-
- TYPE
-
- BkgndColor = RECORD { BKCL resources -- these resources determine the color of the }
- redPart: INTEGER; { background of TBkgndGridViews. }
- greenPart: INTEGER;
- bluePart: INTEGER;
- END;
- BkgndColorPtr = ^BkgndColor;
- BkgndColorHdl = ^BkgndColorPtr;
-
- SideColors = RECORD { SDCR resources -- these resources determine the color of the }
- redPartLightestSide: INTEGER;
- greenPartLightestSide: INTEGER;
- bluePartLightestSide: INTEGER;
- redPartLightSide: INTEGER;
- greenPartLightSide: INTEGER;
- bluePartLightSide: INTEGER;
- redPartDarkSide: INTEGER;
- greenPartDarkSide: INTEGER;
- bluePartDarkSide: INTEGER;
- redPartDarkestSide: INTEGER;
- greenPartDarkestSide: INTEGER;
- bluePartDarkestSide: INTEGER;
- END;
- SideColorsPtr = ^SideColors;
- SideColorsHdl = ^SideColorsPtr;
-
- TBkgndGridView = OBJECT(TGridView)
- fBkgndColor: RGBColor;
-
- PROCEDURE TBkgndGridView.IRes (itsDocument: TDocument; itsSuperview: TView; VAR itsParams: Ptr);
- OVERRIDE;
- PROCEDURE TBkgndGridView.Fields (PROCEDURE DoToField (fieldName: Str255; fieldAddr: Ptr; fieldType: INTEGER));
- OVERRIDE;
- PROCEDURE TBkgndGridView.DrawCell (aCell: GridCell; aQDRect: Rect);
- OVERRIDE;
- PROCEDURE TBkgndGridView.DrawBkgnd (aCell: GridCell; aQDRect: Rect);
- PROCEDURE TBkgndGridView.AdornFirstRowsTop (area: Rect);
- PROCEDURE TBkgndGridView.AdornRow (aRow: INTEGER; area: Rect);
- OVERRIDE;
- PROCEDURE TBkgndGridView.AdornFirstColsLeft (area: Rect);
- PROCEDURE TBkgndGridView.AdornCol (aCol: INTEGER; area: Rect);
- OVERRIDE;
- PROCEDURE TBkgndGridView.SetColor (newColor: RGBColor);
- FUNCTION TBkgndGridView.GetColor: RGBColor;
-
- PROCEDURE TBkgndGridView.GetBkgndColor;
- END;
-
- TReliefGridView = OBJECT(TBkgndGridView)
- fLightestSideColor: RGBColor;
- fLightSideColor: RGBColor;
- fDarkSideColor: RGBColor;
- fDarkestSideColor: RGBColor;
- fSideWidth: Integer;
-
- PROCEDURE TReliefGridView.IRes (itsDocument: TDocument; itsSuperview: TView; VAR itsParams: Ptr);
- OVERRIDE;
- PROCEDURE TReliefGridView.Fields (PROCEDURE DoToField (fieldName: Str255; fieldAddr: Ptr; fieldType: INTEGER));
- OVERRIDE;
-
- { Drawing }
- PROCEDURE TReliefGridView.DrawCell (aCell: GridCell; aQDRect: Rect); OVERRIDE;
- PROCEDURE TReliefGridView.DrawSides (aCell: GridCell; aQDRect: Rect);
- PROCEDURE TReliefGridView.DrawSunkenSides (aCell: GridCell; aQDRect: Rect);
- PROCEDURE TReliefGridView.DrawRaisedSides (aCell: GridCell; aQDRect: Rect);
-
- { Setting and Getting instance variables }
- PROCEDURE TReliefGridView.SetLightColor (newColor: RGBColor);
- FUNCTION TReliefGridView.GetLightColor: RGBColor;
- PROCEDURE TReliefGridView.SetDarkColor (newColor: RGBColor);
- FUNCTION TReliefGridView.GetDarkColor: RGBColor;
- PROCEDURE TReliefGridView.GetSideColors;
- END;
-
- { ••••• Implementation ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• }
- IMPLEMENTATION
-
- PROCEDURE TBkgndGridView.IRes (itsDocument: TDocument; itsSuperview: TView; VAR itsParams: Ptr);
- OVERRIDE;
- BEGIN
- INHERITED IRes(itsDocument, itsSuperView, itsParams);
- { Set the background color defaults, then look for a resource }
- SELF.fBkgndColor.red := 1000;
- SELF.fBkgndColor.green := 30000;
- SELF.fBkgndColor.blue := 1000;
-
- SELF.GetBkgndColor;
- END;
-
- {$S AFields}
-
- PROCEDURE TBkgndGridView.Fields (PROCEDURE DoToField (fieldName: Str255; fieldAddr: Ptr; fieldType: INTEGER));
- OVERRIDE;
-
- BEGIN
- DoToField('TGridView', NIL, bClass);
- DoToField('fBkgndColor', @fBkgndColor, bRGBColor);
-
- INHERITED Fields(DoToField);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
- PROCEDURE TBkgndGridView.AdornCol (aCol: INTEGER; area: Rect);
- OVERRIDE;
- BEGIN
- PenNormal;
- PenSize(SELF.fColInset, SELF.fColInset);
-
- WITH area DO
- BEGIN
- MoveTo(right - (SELF.fColInset DIV 2), top);
- LineTo(right - (SELF.fColInset DIV 2), bottom - SELF.fColInset);
- END;
-
- IF aCol = 1 THEN { for the first column }
- WITH area DO
- BEGIN
- MoveTo(left, top);
- LineTo(left, bottom - 1);
- END;
-
- END;
-
-
- PROCEDURE TBkgndGridView.AdornFirstColsLeft (area: Rect);
- BEGIN
- PenNormal;
- PenSize(SELF.fColInset DIV 2, SELF.fColInset DIV 2); { Only need half the line width, since there is no col }
- { inset for the preceeding col -- there is NO preceeding }
- { col .}
- WITH area DO
- BEGIN
- MoveTo(left, top);
- LineTo(left, bottom - 1);
- END;
-
- END;
-
- PROCEDURE TBkgndGridView.AdornRow (aRow: INTEGER; area: Rect);
- OVERRIDE;
- BEGIN
- PenNormal;
- PenSize(SELF.fRowInset, SELF.fRowInset);
-
- WITH area DO
- BEGIN
- MoveTo(left, bottom - (SELF.fRowInset DIV 2));
- LineTo(right - SELF.fRowInset, bottom - (SELF.fRowInset DIV 2));
- END;
-
- IF aRow = 1 THEN { for the first row }
- SELF.AdornFirstRowsTop(area);
- END;
-
- PROCEDURE TBkgndGridView.AdornFirstRowsTop (area: Rect);
- BEGIN
- PenNormal;
- PenSize(SELF.fRowInset DIV 2, SELF.fRowInset DIV 2); { Only need half the line width, since there is no row }
- { inset for the preceeding row -- there is NO preceeding }
- { row .}
- WITH area DO
- BEGIN
- MoveTo(left, top);
- LineTo(right, top);
- END;
-
- END;
-
- PROCEDURE TBkgndGridView.DrawBkgnd (aCell: GridCell; aQDRect: Rect);
- VAR
- oldBkgndColor: RGBColor;
- newBkgndColor: RGBColor;
- BEGIN
- GetIfColor(oldBkgndColor);
-
- newBkgndColor := SELF.fBkgndColor;
- SetIfColor(newBkgndColor);
-
- FillRect(aQDRect, black);
-
- SetIfColor(oldBkgndColor);
- END;
-
-
- PROCEDURE TBkgndGridView.DrawCell (aCell: GridCell; aQDRect: Rect);
- BEGIN
- SELF.DrawBkgnd(aCell, aQDRect);
- END;
-
-
- PROCEDURE TBkgndGridView.GetBkgndColor;
- VAR
- initialBkgndColor: BkgndColorHdl;
- BEGIN
-
- initialBkgndColor := NIL;
- initialBkgndColor := BkgndColorHdl(Get1Resource(kBkgndColorRsrcType, 800));
- FailNIL(initialBkgndColor);
- FailResError;
-
- WITH initialBkgndColor^^ DO
- BEGIN
- SELF.fBkgndColor.red := redPart;
- SELF.fBkgndColor.green := greenPart;
- SELF.fBkgndColor.blue := bluePart;
- END;
- END;
-
-
- FUNCTION TBkgndGridView.GetColor: RGBColor;
- BEGIN
- GetColor := SELF.fBkgndColor;
- END;
-
-
- PROCEDURE TBkgndGridView.SetColor (newColor: RGBColor);
- BEGIN
- SELF.fBkgndColor := newColor;
- END;
-
-
-
- { ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• }
-
- PROCEDURE TReliefGridView.IRes (itsDocument: TDocument; itsSuperview: TView; VAR itsParams: Ptr);
- OVERRIDE;
- BEGIN
- INHERITED IRes(itsDocument, itsSuperView, itsParams);
-
- { Set the side colors defaults, then look for a resource }
- SELF.fLightestSideColor.red := 26000;
- SELF.fLightestSideColor.green := 31000;
- SELF.fLightestSideColor.blue := 0;
-
- SELF.fLightSideColor.red := 26000;
- SELF.fLightSideColor.green := 31000;
- SELF.fLightSideColor.blue := 0;
-
- SELF.fDarkSideColor.red := 500;
- SELF.fDarkSideColor.green := 15000;
- SELF.fDarkSideColor.blue := 500;
-
- SELF.fDarkestSideColor.red := 500;
- SELF.fDarkestSideColor.green := 15000;
- SELF.fDarkestSideColor.blue := 500;
-
- SELF.fSideWidth := 3;
-
- SELF.GetSideColors;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S AFields}
- PROCEDURE TReliefGridView.Fields (PROCEDURE DoToField (fieldName: Str255; fieldAddr: Ptr; fieldType: INTEGER));
- OVERRIDE;
-
- BEGIN
- DoToField('TGridView', NIL, bClass);
- DoToField('fLightestSideColor', @fLightestSideColor, bRGBColor);
- DoToField('fLightSideColor', @fLightSideColor, bRGBColor);
- DoToField('fDarkSideColor', @fDarkSideColor, bRGBColor);
- DoToField('fDarkestSideColor', @fDarkestSideColor, bRGBColor);
- DoToField('fSideWidth', @fSideWidth, bInteger);
-
- INHERITED Fields(DoToField);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
- PROCEDURE TReliefGridView.DrawCell (aCell: GridCell; aQDRect: Rect);
- BEGIN
- INHERITED DrawCell(aCell, aQDRect);
-
- SELF.DrawSides(aCell, aQDRect);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
- PROCEDURE TReliefGridView.DrawSides (aCell: GridCell; aQDRect: Rect);
- VAR
- oldColor: RGBColor;
- newColor: RGBColor;
- i: INTEGER; { DO Loop index }
-
- BEGIN
- GetIfColor(oldColor);
-
- WITH aQDRect DO
- BEGIN
- newColor := SELF.fLightestSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(left + i, top + i); { Left Side line - Lightest side color }
- LineTo(left + i, bottom - 1);
- END;
-
- newColor := SELF.fLightSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(left + i, top + i); { Top line - Light side color }
- LineTo(right - 1, top + i);
- END;
-
- newColor := SELF.fDarkSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(left + i, bottom - 1 - i); { Bottom line - Dark side color }
- LineTo(right - 1, bottom - 1 - i);
- END;
-
- newColor := SELF.fDarkestSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(right - 1 - i, top + 1 + i); { Right side line - Darkest side color }
- LineTo(right - 1 - i, bottom - 1 - i);
- END;
- END;
-
- SetIfColor(oldColor);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
- PROCEDURE TReliefGridView.DrawRaisedSides (aCell: GridCell; aQDRect: Rect);
- VAR
- oldColor: RGBColor;
- newColor: RGBColor;
- i: INTEGER; { DO Loop index }
-
- BEGIN
- GetIfColor(oldColor);
-
- WITH aQDRect DO
- BEGIN
- newColor := SELF.fLightestSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(left + i, top + i); { Left Side line - now, the darkest side color }
- LineTo(left + i, bottom - 2);
- END;
-
- newColor := SELF.fLightSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(left + i, top + i); { Top line - now, the dark side color }
- LineTo(right - 2, top + i);
- END;
-
- newColor := SELF.fDarkSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(left + i, bottom - 2 - i); { Bottom line - Dark side color }
- LineTo(right - 2, bottom - 2 - i);
- END;
-
- newColor := SELF.fDarkestSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(right - 2 - i, top + 1 + i); { Right side line - Darkest side color }
- LineTo(right - 2 - i, bottom - 2 - i);
- END;
- END;
-
- SetIfColor(oldColor);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
- PROCEDURE TReliefGridView.DrawSunkenSides (aCell: GridCell; aQDRect: Rect);
- VAR
- oldColor: RGBColor;
- newColor: RGBColor;
- i: INTEGER; { DO Loop index }
-
- BEGIN
- GetIfColor(oldColor);
-
- WITH aQDRect DO
- BEGIN
- newColor := SELF.fDarkestSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(left + i, top + i); { Left Side line - now, the darkest side color }
- LineTo(left + i, bottom - 2);
- END;
-
- newColor := SELF.fDarkSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(left + i, top + i); { Top line - now, the dark side color }
- LineTo(right - 2, top + i);
- END;
-
- newColor := SELF.fLightSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(left + i, bottom - 2 - i); { Bottom line - Dark side color }
- LineTo(right - 2, bottom - 2 - i);
- END;
-
- newColor := SELF.fLightestSideColor;
- SetIfColor(newColor);
- FOR i := 0 TO (SELF.fSideWidth - 1) DO
- BEGIN
- MoveTo(right - 2 - i, top + 1 + i); { Right side line - Darkest side color }
- LineTo(right - 2 - i, bottom - 2 - i);
- END;
- END;
-
- SetIfColor(oldColor);
- END;
-
-
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
- PROCEDURE TReliefGridView.GetSideColors;
- VAR
- initialSideColors: SideColorsHdl;
- BEGIN
-
- initialSideColors := NIL;
- initialSideColors := SideColorsHdl(Get1Resource(kSideColorRsrcType, 800));
- FailNIL(initialSideColors);
- FailResError;
-
- WITH initialSideColors^^ DO
- BEGIN
- SELF.fLightestSideColor.red := redPartLightestSide;
- SELF.fLightestSideColor.green := greenPartLightestSide;
- SELF.fLightestSideColor.blue := bluePartLightestSide;
-
- SELF.fLightSideColor.red := redPartLightSide;
- SELF.fLightSideColor.green := greenPartLightSide;
- SELF.fLightSideColor.blue := bluePartLightSide;
-
- SELF.fDarkSideColor.red := redPartDarkSide;
- SELF.fDarkSideColor.green := greenPartDarkSide;
- SELF.fDarkSideColor.blue := bluePartDarkSide;
-
- SELF.fDarkestSideColor.red := redPartDarkestSide;
- SELF.fDarkestSideColor.green := greenPartDarkestSide;
- SELF.fDarkestSideColor.blue := bluePartDarkestSide;
- END;
- END;
-
-
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
- PROCEDURE TReliefGridView.SetLightColor (newColor: RGBColor);
- BEGIN
- END;
-
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
- FUNCTION TReliefGridView.GetLightColor: RGBColor;
- BEGIN
- END;
-
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
- PROCEDURE TReliefGridView.SetDarkColor (newColor: RGBColor);
- BEGIN
- END;
-
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
- FUNCTION TReliefGridView.GetDarkColor: RGBColor;
- BEGIN
- END;
-
-
-
- END.